package com.hex.ds.hdrs.agent.dao;

import com.hex.bigdata.hbda.base.BaseDao;
import com.hex.bigdata.hbda.base.Page;
import com.hex.ds.hdrs.agent.po.AgentHeartbeatLog;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

/**
 * @Package: com.hex.ds.hdrs.agent.dao
 * @ClassName AgentHeartbeatLogDao
 * @Description:agent心跳日志表
 * @Author: <gc.zuo>
 * @Date 2021/6/3 15:35
 * @Version v1.0
 **/
@Repository
public class AgentHeartbeatLogDao extends BaseDao {

    public void insert(AgentHeartbeatLog agentHeartbeatLog) {
        this.insert("com.hex.ds.hdrs.agent.dao.AgentHeartbeatLogDao.insert", agentHeartbeatLog);
    }

    public List<AgentHeartbeatLog> queryHeartbeatLog(Map map, Page page) {
        return this.selectPage(AgentHeartbeatLog.class, "com.hex.ds.hdrs.agent.dao.AgentHeartbeatLogDao.selectAll", page, map);
    }

    /**
     * 查询节点心跳日志
     *
     * @param map
     * @return
     */
    public List<AgentHeartbeatLog> qryAgentHeartbeatLog(Map map) {
        return this.selectList(AgentHeartbeatLog.class, "com.hex.ds.hdrs.agent.dao.AgentHeartbeatLogDao.selectAll", map);
    }

    public List<AgentHeartbeatLog> qryHbLog(Map map) {
        return this.selectList(AgentHeartbeatLog.class, "com.hex.ds.hdrs.agent.dao.AgentHeartbeatLogDao.qryHbLog", map);
    }

    public AgentHeartbeatLog getHeartbeatDetail(Map map) {
        return this.selectOne(AgentHeartbeatLog.class, "com.hex.ds.hdrs.agent.dao.AgentHeartbeatLogDao.qryHbLog", map);
    }

    public AgentHeartbeatLog qryLastHeartBeat(String agentCode) {
        return this.selectOne(AgentHeartbeatLog.class, "com.hex.ds.hdrs.agent.dao.AgentHeartbeatLogDao.qryLastHeartBeat", agentCode);
    }

    /**
     * 查询资源数与并发数
     *
     * @param map
     * @return
     */
    public List<Map> getResAndConnList(Map map) {
        return this.selectList(Map.class, "com.hex.ds.hdrs.agent.dao.AgentHeartbeatLogDao.getResAndConnList", map);
    }

    public List<Map> getResAndConnList2(Map map) {
        return this.selectList(Map.class, "com.hex.ds.hdrs.agent.dao.AgentHeartbeatLogDao.getResAndConnList2", map);
    }

    public void delTaskByDate(Map map) {
        this.delete("com.hex.ds.hdrs.agent.dao.AgentHeartbeatLogDao.delTaskByDate", map);
    }

    public void reductionHeartbeatLogTask(String bitchId) {
        this.insert("com.hex.ds.hdrs.agent.dao.AgentHeartbeatLogDao.reductionHeartbeatLogTask", bitchId);
    }

    public void edit(AgentHeartbeatLog agentHeartbeatLog) {
        this.update("com.hex.ds.hdrs.agent.dao.AgentHeartbeatLogDao.edit",agentHeartbeatLog);
    }
}